	<?php /* @var $this Controller */ 
$currUser = "";
$level = 0;
$unlockedAllFunctions = false;
$hasProfile = false;
$ccaPointsMenuArray = array();
if(!Yii::app()->user->isGuest){
	if(isset(Yii::app()->user->userModel)){
		$currUser = Yii::app()->user->userModel->matric_no;
		$matric_no = Yii::app()->user->userModel->matric_no;
		$criteria = new CDbCriteria;
		$criteria->condition = "matric_no = '$matric_no'";
		$user_model = Resident::model()->find($criteria);
		$level = 999;
		$hasProfile = true;
		foreach($user_model->ccaResidents as $ccaResident){
			if($ccaResident->role->level <= 2){
				$unlockedAllFunctions = true;
				break;
			}
			if($ccaResident->role->level<=4){
				array_push($ccaPointsMenuArray, array('label'=>$ccaResident->cca->name, 'url'=>array('/ccaResident/admin/', 'CcaResident[cca_name]'=>$ccaResident->cca->name), 'visible'=>true));
                                array_push($ccaPointsMenuArray, array('label'=>'points', 'url'=>array('/pointRecord/admin/'), 'visible'=>true));
			}
		}
		
	}else{
		$currUser = "Super Admin";
		$level = Yii::app()->user->level;
		$unlockedAllFunctions = true;
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />

	<!-- blueprint CSS framework -->
	<!-- <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" /> -->
	<!--  <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" /> -->
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
	<![endif]-->
	<!-- <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" /> -->
	<!-- <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" /> -->
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-3.0.0/dist/css/bootstrap.min.css" />


	<title><?php echo CHtml::encode($this->pageTitle); ?></title>
</head>

<body>

<div class="container" id="page">

	<header>
		<div id="logo"><h1><?php echo CHtml::encode(Yii::app()->name); ?></h1></div>
	</header><!-- header -->

	<div id="mainmenu">
		<?php $this->widget('zii.widgets.CMenu',array(
			'items'=>array(
				array('label'=>'Home', 'url'=>array('/site/index')),
				//array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),
				//array('label'=>'Contact', 'url'=>array('/site/contact')),
				array('label'=>'Profile', 'url'=>array('/profile'), 'visible'=>!Yii::app()->user->isGuest && $hasProfile),
				array('label'=>'Residents', 'url'=>array('/resident/admin'), 'visible'=>!Yii::app()->user->isGuest && $unlockedAllFunctions),
				array('label'=>'CCA', 'url'=>array('/cca/admin'), 'visible'=>!Yii::app()->user->isGuest&& $unlockedAllFunctions),
				array('label'=>'CCA Residents', 'url'=>array('/ccaResident/admin'), 'visible'=>!Yii::app()->user->isGuest&& $unlockedAllFunctions),
				array('label'=>'Roles', 'url'=>array('/role/admin'), 'visible'=>!Yii::app()->user->isGuest&& $unlockedAllFunctions),

//				array('label'=>'Add Comm Application', 'url'=>array('/apply/create'), 'visible'=>!Yii::app()->user->isGuest&& $unlockedAllFunctions),
				array('label'=>'Export', 'url'=>array('/export'), 'visible'=>!Yii::app()->user->isGuest&& $unlockedAllFunctions),
				array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
				array('label'=>'Logout ('.$currUser.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
			),
			'htmlOptions'=>array(
				'class'=>'nav navbar-nav navbar-default',
			)
		)); ?>
		<?php $this->widget('zii.widgets.CMenu',array(
			'items'=>$ccaPointsMenuArray
			,
			'htmlOptions'=>array(
				'class'=>'nav navbar-nav navbar-default',
			))); ?>
	</div><!-- mainmenu -->
  <div class="clearfix"></div>


	<?php echo $content; ?>

	<div class="clear"></div>

	<div id="footer">
		Copyright &copy; <?php echo date('Y'); ?> KR - MSU.<br/>
		All Rights Reserved.<br/>
		<?php echo Yii::powered(); ?>
	</div><!-- footer -->

</div><!-- page -->

</body>
</html>
